﻿using CrediSoftDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ActivityLibrary;
using Activities;
using System.Activities;

namespace CrediSoftDemo.Controllers
{
    public class GestionCategoriaController : Controller
    {
        //
        // GET: /GestionCategoria/
        GestionCategoriaModel gestCatDAO = new GestionCategoriaModel();

        public ActionResult IndexGestionCategoria()
        {
            ActivityController.StartActivity();
            return View();
        }

        public ActionResult UnaVista()
        {
            return View();
        }


        [HttpPost]
        public string WorkFlow(string number)
        {
            if (number != null && number != "")
            {
                int guess = Convert.ToInt32(number);
                ActivityController.TryGuess(guess);
                return ActivityController.GetMessage();
            }
            else
                return "";
        }
        
        [HttpPost]
        public JsonResult insert(GestionCategoriaDao jason)
        {
            category catego = new category();
            catego = gestCatDAO.insert(jason);
            return Json(catego);
        }

        [HttpPost]
        public JsonResult search(GestionCategoriaDao jason)
        {
            List<category> result=null;
            result = gestCatDAO.search(jason);
            if (result == null) { return Json("No se encontró."); }
            return Json(result);
        }

        [HttpPost]
        public JsonResult modify(GestionCategoriaDao jason)
        {
            string cad = gestCatDAO.modify(jason);
            return Json(cad);
        }

        [HttpPost]
        public JsonResult delete(GestionCategoriaDao jason)
        {
            string cad = gestCatDAO.delete(jason);
            return Json(cad);
        }

        [HttpPost]
        public JsonResult test1(string jason)
        {
            string result = "Envio: " + jason;
            return Json(result);
        }
    }
}
